<?php
/**
 * 后台上传处理控制器，勿删
 */
namespace Admin\Controller;
use Think\Controller;
use Common\Lib\Upload;

class UploadController extends Controller {

	//通过表单提交的图片上传
   public function image(){
       $upload = new Upload();
       $image_info = $upload->image('Filedata');
       
       $attachment_id = $image_info['attachment_id'];
       $this->ajaxReturn(array(
           'src' => image($attachment_id),
           'attachment_id' => $attachment_id,
       ));

   }
   //通过Kindeditor提交
   public function kindeditor(){
       //判断是否上传图片
       if($_FILES['imgFile']['name']){
           $upload = new Upload();
           //$upload->upload_thumb_width = '50';
           //$upload->upload_thumb_height = '50';
           $upload_info = $upload->image('imgFile', 1);
       
           if($upload_info['error']){
               $this->ajaxReturn(array('error' => 1, 'message' => $upload_info['message']));
           }else{
               $this->ajaxReturn(array('error' => 0, 'url' => thumb($upload_info['attachment_id'])));
           }
       }
   }
   
   //通过UEditor提交，todo
   public function ueditor(){
       
   }
   

}